/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package org.teacup.eightdays.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import org.teacup.eightdays.model.*;
import org.teacup.eightdays.dao.*;
import org.teacup.eightdays.service.*;
import org.teacup.eightdays.vo.query.*;

/**
 * @author Abner email:521yexu2008(a)163.com
 * @version 1.0
 * @since 1.0
 */

@Entity
@Table(name = "order_item")
public class OrderItem extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "OrderItem";
	public static final String ALIAS_ORDER_ITEM_ID = "ID";
	public static final String ALIAS_ORDER_ID = "订单ID";
	public static final String ALIAS_PRODUCT_ID = "产品ID";
	public static final String ALIAS_NAME = "产品名称";
	public static final String ALIAS_CODE = "商品编号";
	public static final String ALIAS_PRODUCT_TYPE = "产品类型名称";
	public static final String ALIAS_PRODUCT_DESCRIBE = "描述";
	public static final String ALIAS_PRODUCING_AREA = "产地";
	public static final String ALIAS_PRODUCTION_CERTIFICATE = "生产许可证编号";
	public static final String ALIAS_PRODUCT_STANDARD_CODE = "产品标准号";
	public static final String ALIAS_WORKS_INITIALS = "厂名";
	public static final String ALIAS_WORKS_ADDRESS = "厂址";
	public static final String ALIAS_BURDEN_SHEET = "配料表";
	public static final String ALIAS_STORE = "储藏方法";
	public static final String ALIAS_QUALITY_GUARANTEE_PERIOD = "保质期";
	public static final String ALIAS_ADDITIVE = "食品添加剂";
	public static final String ALIAS_PACKAGING = "包装方式";
	public static final String ALIAS_BRAND = "品牌";
	public static final String ALIAS_CATENA = "系列";
	public static final String ALIAS_STANDARD = "规格";
	public static final String ALIAS_BAR_CODE = "商品条码";
	public static final String ALIAS_WEIGHT = "重量";
	public static final String ALIAS_TYPE = "种类";
	public static final String ALIAS_COST = "成本价";
	public static final String ALIAS_PRICE = "销售价";
	public static final String ALIAS_NUMBER = "数量";
	public static final String ALIAS_AMOUNT = "总价";
	public static final String ALIAS_TASTE = "口味";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * ID       db_column: order_item_id 
     */ 	
	
	private java.lang.Long orderItemId;
    /**
     * 订单ID       db_column: order_id 
     */ 	
	
	private java.lang.Long orderId;
    /**
     * 产品ID       db_column: product_id 
     */ 	
	
	private java.lang.Long productId;
    /**
     * 产品名称       db_column: name 
     */ 	
	@NotBlank @Length(max=255)
	private java.lang.String name;
    /**
     * 商品编号       db_column: code 
     */ 	
	@NotBlank @Length(max=100)
	private java.lang.String code;
    /**
     * 产品类型名称       db_column: product_type 
     */ 	
	@Length(max=255)
	private java.lang.String productType;
    /**
     * 描述       db_column: product_describe 
     */ 	
	@NotBlank @Length(max=500)
	private java.lang.String productDescribe;
    /**
     * 产地       db_column: producing_area 
     */ 	
	@Length(max=255)
	private java.lang.String producingArea;
    /**
     * 生产许可证编号       db_column: production_certificate 
     */ 	
	@Length(max=255)
	private java.lang.String productionCertificate;
    /**
     * 产品标准号       db_column: product_standard_code 
     */ 	
	@Length(max=255)
	private java.lang.String productStandardCode;
    /**
     * 厂名       db_column: works_initials 
     */ 	
	@Length(max=500)
	private java.lang.String worksInitials;
    /**
     * 厂址       db_column: works_address 
     */ 	
	@Length(max=500)
	private java.lang.String worksAddress;
    /**
     * 配料表       db_column: burden_sheet 
     */ 	
	@Length(max=1000)
	private java.lang.String burdenSheet;
    /**
     * 储藏方法       db_column: store 
     */ 	
	@Length(max=255)
	private java.lang.String store;
    /**
     * 保质期       db_column: quality_guarantee_period 
     */ 	
	@Length(max=255)
	private java.lang.String qualityGuaranteePeriod;
    /**
     * 食品添加剂       db_column: additive 
     */ 	
	@Length(max=255)
	private java.lang.String additive;
    /**
     * 包装方式       db_column: packaging 
     */ 	
	@Length(max=255)
	private java.lang.String packaging;
    /**
     * 品牌       db_column: brand 
     */ 	
	@Length(max=255)
	private java.lang.String brand;
    /**
     * 系列       db_column: catena 
     */ 	
	@Length(max=255)
	private java.lang.String catena;
    /**
     * 规格       db_column: standard 
     */ 	
	@Length(max=100)
	private java.lang.String standard;
    /**
     * 商品条码       db_column: bar_code 
     */ 	
	@Length(max=255)
	private java.lang.String barCode;
    /**
     * 重量       db_column: weight 
     */ 	
	@Length(max=255)
	private java.lang.String weight;
    /**
     * 种类       db_column: type 
     */ 	
	@Length(max=255)
	private java.lang.String type;
    /**
     * 成本价       db_column: cost 
     */ 	
	@NotNull 
	private java.lang.Float cost;
    /**
     * 销售价       db_column: price 
     */ 	
	@NotNull 
	private java.lang.Float price;
    /**
     * 数量       db_column: number 
     */ 	
	
	private java.lang.Integer number;
    /**
     * 总价       db_column: amount 
     */ 	
	
	private java.lang.Float amount;
    /**
     * 口味       db_column: taste 
     */ 	
	@Length(max=100)
	private java.lang.String taste;
	//columns END


	public OrderItem(){
	}

	public OrderItem(
		java.lang.Long orderItemId
	){
		this.orderItemId = orderItemId;
	}

	

	public void setOrderItemId(java.lang.Long value) {
		this.orderItemId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "order_item_id", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getOrderItemId() {
		return this.orderItemId;
	}
	
	@Column(name = "order_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getOrderId() {
		return this.orderId;
	}
	
	public void setOrderId(java.lang.Long value) {
		this.orderId = value;
	}
	
	@Column(name = "product_id", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getProductId() {
		return this.productId;
	}
	
	public void setProductId(java.lang.Long value) {
		this.productId = value;
	}
	
	@Column(name = "name", unique = false, nullable = false, insertable = true, updatable = true, length = 255)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	
	@Column(name = "code", unique = false, nullable = false, insertable = true, updatable = true, length = 100)
	public java.lang.String getCode() {
		return this.code;
	}
	
	public void setCode(java.lang.String value) {
		this.code = value;
	}
	
	@Column(name = "product_type", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getProductType() {
		return this.productType;
	}
	
	public void setProductType(java.lang.String value) {
		this.productType = value;
	}
	
	@Column(name = "product_describe", unique = false, nullable = false, insertable = true, updatable = true, length = 500)
	public java.lang.String getProductDescribe() {
		return this.productDescribe;
	}
	
	public void setProductDescribe(java.lang.String value) {
		this.productDescribe = value;
	}
	
	@Column(name = "producing_area", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getProducingArea() {
		return this.producingArea;
	}
	
	public void setProducingArea(java.lang.String value) {
		this.producingArea = value;
	}
	
	@Column(name = "production_certificate", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getProductionCertificate() {
		return this.productionCertificate;
	}
	
	public void setProductionCertificate(java.lang.String value) {
		this.productionCertificate = value;
	}
	
	@Column(name = "product_standard_code", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getProductStandardCode() {
		return this.productStandardCode;
	}
	
	public void setProductStandardCode(java.lang.String value) {
		this.productStandardCode = value;
	}
	
	@Column(name = "works_initials", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getWorksInitials() {
		return this.worksInitials;
	}
	
	public void setWorksInitials(java.lang.String value) {
		this.worksInitials = value;
	}
	
	@Column(name = "works_address", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getWorksAddress() {
		return this.worksAddress;
	}
	
	public void setWorksAddress(java.lang.String value) {
		this.worksAddress = value;
	}
	
	@Column(name = "burden_sheet", unique = false, nullable = true, insertable = true, updatable = true, length = 1000)
	public java.lang.String getBurdenSheet() {
		return this.burdenSheet;
	}
	
	public void setBurdenSheet(java.lang.String value) {
		this.burdenSheet = value;
	}
	
	@Column(name = "store", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getStore() {
		return this.store;
	}
	
	public void setStore(java.lang.String value) {
		this.store = value;
	}
	
	@Column(name = "quality_guarantee_period", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getQualityGuaranteePeriod() {
		return this.qualityGuaranteePeriod;
	}
	
	public void setQualityGuaranteePeriod(java.lang.String value) {
		this.qualityGuaranteePeriod = value;
	}
	
	@Column(name = "additive", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getAdditive() {
		return this.additive;
	}
	
	public void setAdditive(java.lang.String value) {
		this.additive = value;
	}
	
	@Column(name = "packaging", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getPackaging() {
		return this.packaging;
	}
	
	public void setPackaging(java.lang.String value) {
		this.packaging = value;
	}
	
	@Column(name = "brand", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getBrand() {
		return this.brand;
	}
	
	public void setBrand(java.lang.String value) {
		this.brand = value;
	}
	
	@Column(name = "catena", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getCatena() {
		return this.catena;
	}
	
	public void setCatena(java.lang.String value) {
		this.catena = value;
	}
	
	@Column(name = "standard", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getStandard() {
		return this.standard;
	}
	
	public void setStandard(java.lang.String value) {
		this.standard = value;
	}
	
	@Column(name = "bar_code", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getBarCode() {
		return this.barCode;
	}
	
	public void setBarCode(java.lang.String value) {
		this.barCode = value;
	}
	
	@Column(name = "weight", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getWeight() {
		return this.weight;
	}
	
	public void setWeight(java.lang.String value) {
		this.weight = value;
	}
	
	@Column(name = "type", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getType() {
		return this.type;
	}
	
	public void setType(java.lang.String value) {
		this.type = value;
	}
	
	@Column(name = "cost", unique = false, nullable = false, insertable = true, updatable = true, length = 12)
	public java.lang.Float getCost() {
		return this.cost;
	}
	
	public void setCost(java.lang.Float value) {
		this.cost = value;
	}
	
	@Column(name = "price", unique = false, nullable = false, insertable = true, updatable = true, length = 12)
	public java.lang.Float getPrice() {
		return this.price;
	}
	
	public void setPrice(java.lang.Float value) {
		this.price = value;
	}
	
	@Column(name = "number", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getNumber() {
		return this.number;
	}
	
	public void setNumber(java.lang.Integer value) {
		this.number = value;
	}
	
	@Column(name = "amount", unique = false, nullable = true, insertable = true, updatable = true, length = 12)
	public java.lang.Float getAmount() {
		return this.amount;
	}
	
	public void setAmount(java.lang.Float value) {
		this.amount = value;
	}
	
	@Column(name = "taste", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getTaste() {
		return this.taste;
	}
	
	public void setTaste(java.lang.String value) {
		this.taste = value;
	}
	
	
	private Product product;
	public void setProduct(Product product){
		this.product = product;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "product_id",nullable = false, insertable = false, updatable = false) 
	})
	public Product getProduct() {
		return product;
	}
	
	private Orderinfo orderinfo;
	public void setOrderinfo(Orderinfo orderinfo){
		this.orderinfo = orderinfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "order_id",nullable = false, insertable = false, updatable = false) 
	})
	public Orderinfo getOrderinfo() {
		return orderinfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("OrderItemId",getOrderItemId())
			.append("OrderId",getOrderId())
			.append("ProductId",getProductId())
			.append("Name",getName())
			.append("Code",getCode())
			.append("ProductType",getProductType())
			.append("ProductDescribe",getProductDescribe())
			.append("ProducingArea",getProducingArea())
			.append("ProductionCertificate",getProductionCertificate())
			.append("ProductStandardCode",getProductStandardCode())
			.append("WorksInitials",getWorksInitials())
			.append("WorksAddress",getWorksAddress())
			.append("BurdenSheet",getBurdenSheet())
			.append("Store",getStore())
			.append("QualityGuaranteePeriod",getQualityGuaranteePeriod())
			.append("Additive",getAdditive())
			.append("Packaging",getPackaging())
			.append("Brand",getBrand())
			.append("Catena",getCatena())
			.append("Standard",getStandard())
			.append("BarCode",getBarCode())
			.append("Weight",getWeight())
			.append("Type",getType())
			.append("Cost",getCost())
			.append("Price",getPrice())
			.append("Number",getNumber())
			.append("Amount",getAmount())
			.append("Taste",getTaste())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getOrderItemId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof OrderItem == false) return false;
		if(this == obj) return true;
		OrderItem other = (OrderItem)obj;
		return new EqualsBuilder()
			.append(getOrderItemId(),other.getOrderItemId())
			.isEquals();
	}
}

